package com.cswangdao.controller.admin;



import com.cswangdao.domain.dto.CommentPageDTO;
import com.cswangdao.domain.model.MarketComment;
import com.cswangdao.result.PageResult;
import com.cswangdao.result.Result;
import com.cswangdao.service.CommentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;

@RequestMapping("/admin/comment")
@RestController
@Slf4j
public class AdminCommentController {

    @Autowired
    private CommentService commentService;

    /**
     * @description: 分页查询评论信息
     * @param: request,response
     * @return: void
     */
    @GetMapping("/list")
    public Result<PageResult<MarketComment>> list(CommentPageDTO pageDTO) {
        log.info("分页查询评论信息:{}",pageDTO);
        PageResult<MarketComment> pageResult = commentService.pageQueryInfo(pageDTO);
       return Result.success(pageResult);
    }

    /**
     * @description: 删除评论信息
     * @param: request,response
     * @return: void
     */
    @PostMapping("/delete")
    public Result delete(@RequestBody MarketComment comment) throws IOException {
        log.info("删除评论信息:{}",comment);
        commentService.deleteById(comment.getId());
        return Result.success();
    }

}
